package com.mdxx.xczd.db.bo;

import android.content.ContentValues;
import android.content.Context;

import com.mdxx.xczd.db.dao.LocationServerDAO;
import com.mdxx.xczd.db.dao.ServerDAO;

import java.util.List;

public class LocationDataBO {

	private ServerDAO serverDAO;

	public LocationDataBO(Context context){
		serverDAO = new LocationServerDAO(context);
	}
	
	/**
	 * 存位置数据
	 */
	public boolean insertLocationData(String infos) {
		boolean flag = false;
		ContentValues values = new ContentValues();
		values.put("location", infos);
		values.put("issend", 0);
		flag = serverDAO.add("location", values);
		return flag;
	}
	/*public boolean insertLocationData(LocationAndNetWorkBean infos) {
		boolean flag = false;
		TimeInfoBean realTimeInfo = infos.getTimeInfoBean() ;
		Coordinate coordinate = infos.getCoordinate();
		Point clola = coordinate.getClola();
		ContentValues values = new ContentValues();
		values.put("taskNum", coordinate.getTaskNum());
		values.put("cTime", coordinate.getcTime());
		values.put("lo", clola.getLongitude());
		values.put("la", clola.getLatitude());
		values.put("cellularSignalStrength", realTimeInfo.getCellularSignalStrength());
		values.put("networkStrength", realTimeInfo.getNetworkStrength());
		values.put("cellID", realTimeInfo.getCellID());
		values.put("locationType", realTimeInfo.getLocationType());
		values.put("satelliteNum", realTimeInfo.getSatelliteNum());
		values.put("power", realTimeInfo.getPower());
		flag = serverDAO.add("location", values);
		return flag;
	}*/

	/**
	 * 查位置数据
	 */
	public List<String> queryLocationData() {
		String sql = "select * from location where issend = 0";
		List<String> list = serverDAO.queryMulti(sql);
		return list;
	}

	public boolean updateLocationData(String url) {
		String sql = "update location set issend = 1 where location ="+"'"+url+"'";
		boolean flag = serverDAO.update(sql);
		return flag;
	}
	
	
	/**
	 * 删位置数据
	 */
	public void delLocationData() {
		String sql = "delete from location where issend = 1";
		serverDAO.delete(sql);
	}	
}
